<template>
  <div ref="AreasChart" :style="{width:width+'px',height:height+'px'}"></div>
</template>
  
<script setup>
import { getCurrentInstance, onMounted } from 'vue'
import * as echarts from 'echarts/core';
import { TooltipComponent, LegendComponent } from 'echarts/components';
import { PieChart } from 'echarts/charts';
import { LabelLayout } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';

const currentInstance = getCurrentInstance()
const props = defineProps({
  width: Number,
  height: Number
})
const {width, height} = props
echarts.use([
  TooltipComponent,
  LegendComponent,
  PieChart,
  CanvasRenderer,
  LabelLayout
]);

let option = {
  tooltip: {
    trigger: 'item'
  },
  legend: {
    top: '5%',
    left: 'center'
  },
  series: [
    {
      name: '领域',
      type: 'pie',
      radius: ['40%', '70%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      label: {
        show: false,
        position: 'center'
      },
      emphasis: {
        label: {
          show: true,
          fontSize: '40',
          fontWeight: 'bold'
        }
      },
      labelLine: {
        show: false
      },
      data: [
        { value: 1048, name: '人工只因' },
        { value: 735, name: '人工智障' },
        { value: 580, name: '爱酱' },
        { value: 484, name: '人工只能' },
        { value: 300, name: '人工智能' }
      ]
    }
  ]
};

onMounted(() => {
  var myChart = echarts.init(currentInstance.refs.AreasChart);
  option && myChart.setOption(option);
})


</script>
  
<style>

</style>